//
// Created by Dell on 2021/12/6.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> origin,pre,preM,post,postM;
struct node{
    int val;
    node *left,*right;
};

void insert(node *& x,int val){
    if(x == nullptr){
        x = new node;
        x->left = nullptr; x->right = nullptr;
        x->val = val;
        return ;
    }
  if (val < x->val){
        insert(x->left,val);
    }else {
        insert(x->right,val);
    }
}

void preOrder(node *x,vector<int>&v){
    if(x == nullptr) return;
    v.push_back(x->val);
    preOrder(x->left,v);
    preOrder(x->right,v);
}

void preOrderMirror(node *x,vector<int>&v){
    if(x == nullptr) return;
    v.push_back(x->val);
    preOrderMirror(x->right,v);
    preOrderMirror(x->left,v);

}

void postOrder(node * x,vector<int> &v){
    if(x == nullptr) return;
    postOrder(x->left,v);
    postOrder(x->right,v);
    v.push_back(x->val);

}

void postOrderMirror(node * x,vector<int> &v){
    if(x == nullptr) return;
    postOrderMirror(x->right,v);
    postOrderMirror(x->left,v);

    v.push_back(x->val);

}

void search(node *x, int val){
    if(x == nullptr){
        printf("%s\n","Fail");
    }
    if(val == x->val){
        printf("%s\n","Yes");
        return ;
    } else if (val < x->val){
        insert(x->left,val);
    }else {
        insert(x->right,val);
    }
}
node *build(int data[],int n){
    node * root = NULL;
    for(int i = 0;i<n;++i){
        insert(root,data[i]);
    }
    return root;
}

node * findMax(node * x){
    while(x->right!=NULL){
        x = x->right;
    }
    return x;
}

node * findMin(node * x){
    while(x->left!=NULL){
        x = x->left;
    }
    return x;
}

void deleteNode(node *x,int val){
    if(x == nullptr){
        return ;
    }
    if(x->val == val){
        if(x ->left == nullptr&&x -> right== nullptr){
            x  = nullptr;
        }else if(x->right != nullptr){
            node * tem = findMin(x->right);
            x ->val = tem->val;
            deleteNode(tem,tem->val);
        }else{
            node * tem = findMax(x->left);
            x ->val =tem->val;
            deleteNode(tem,tem->val);
        }
    }else if(val<x->val){
        deleteNode(x->left,val);
    }else{
        deleteNode(x->right,val);
    }
}

int main(){

    int n,data;
    node * root = nullptr;
    scanf("%d",&n);
    for(int i = 0;i<n;++i){
        scanf("%d",&data);
        origin.push_back(data);
        insert(root,data);
    }
    preOrder(root,pre);
    preOrderMirror(root,preM);
    postOrder(root,post);
    postOrderMirror(root,postM);


    if(origin == pre){
        cout<<"yes"<<'\n';
        for(auto c:post){
            cout<<c<<" ";
        }
    }else if(origin == preM){
        cout<<"yes"<<'\n';
        for(auto c:postM){
            cout<<c<<" ";
        }
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}